<?php
/*
 * Created on 2010-6-2
 * 
 * Filename: member.php
 *
 * Author: szy
 * 
 * TODO: TODO
 *
 */

  //include function files for this application
  require_once('funs/bbox_fns.php');
  require_once('main.php');
  
  if ($_GET['action'] == 'login'){
  //create short variable names
  $email = $_POST['email'];
  $passwd = $_POST['passwd'];
  
  //they have just tried logging in
  if($email && $passwd){
  
    	try{
    		
    	  login($email, $passwd);
    	  
    	  //if they are in the database register the user id
    	  $_SESSION['valid_user'] = $email;
    	 	
    	}
    	catch(Exception $e){
    	
    	  //unsuccessful login
    	  $tpl->assign('error', $e);
    	  $tpl->assign('msg', 'You could not be logged in. You must be logged in to view this page.');
    	  $tpl->assign('back_link', 'index.php');
    	  $tpl->display("error.html");
    	  exit;	  		
    	}  	
  	
  }  //end if
  }
  else if($_GET['action'] == 'link'){
  	
      $_SESSION['valid_user'] = $_GET['sessionid'];	
  }
  
  check_valid_user();
 
?>
